<template>
  <div>
    <el-select style="display: block;" :size="size" v-model="value" placeholder="电子卡状态" clearable @change="changeValue" @clear="changeValue">
      <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"/>
    </el-select>
  </div>
</template>

<script>
import {isNotNull} from "@/util/common-util";

export default {
  name: "electronic-card-status-select",
  props: {
    initValue: {
      type: Object,
      default: null
    },
    size: {
      type: String,
      default: 'small'
    }
  },
  data() {
    return {
      options: [], // “物流停车场、路边店、私人加油站、修理厂、物流企业
      value: ''
    }
  },
  created() {
    this.initOptions(() => {
      if (isNotNull(this.initValue)) {
        this.value = this.initValue
      }
    })
  },
  methods: {
    initOptions(success) {
      // 卡状态（0-未绑定 1-正常 2-停用）
      this.options = [{
        label: '未绑定',
        value: 0
      }, {
        label: '正常',
        value: 1
      }, {
        label: '停用',
        value: 2
      }]
      success && success()
    },
    changeValue() {
      this.$emit('change', this.value)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
